package com.example.chapter_1_17.controller;

import com.example.chapter_1_17.entity.Person;
import com.example.chapter_1_17.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class PersonController {

    @Autowired
    private PersonService personService;
    @RequestMapping("/selectSan")
//    @ResponseBody
    public String selectSan(Model model){
        //已经将我们查询结果放到了 persons里面了
        model.addAttribute("persons",personService.selectList());
        return "person";
    }
}
